//
//  HBChannelItemModel.m
//  HeartBeat
//
//  Created by karong on 2023/8/23.
//

#import "HBChannelItemModel.h"

@implementation HBChannelItemModel
- (BOOL)showHeader {
    BOOL rec = self.style == HBChannelConfigType2;
    return rec;
}

- (NSInteger)row {
    NSInteger count = 0;
    switch (self.style) {
        case HBChannelConfigType2:
        {
            count = self.items.count;
        }
            break;
        case HBChannelConfigType5:
        {
            count = 1;
        }
            break;
        default:
            count = MIN(1, self.items.count);
            break;
    }
    return count;
}

- (NSString *)cellClass {
    NSString * class = @"";
    switch (self.style) {
        case HBChannelConfigType1:
        {
            class = @"HBDiscoverItemHorizontalCell";
        }
            break;
        case HBChannelConfigType2:
        {
            class = @"HBDiscoverItemNovel1Cell";
        }
            break;
        case HBChannelConfigType3:
        {
            class = @"HBDiscoverItemBannerCell";
        }
            break;
        case HBChannelConfigType4:
        {
            class = @"HBDiscoverItemExtraCell";
        }
            break;
        case HBChannelConfigType5:
        {
            class = @"HBDiscoverItemRankListCell";
        }
            break;
        default:
            class = @"HBDiscoverItemNovel2Cell";
            break;
    }
    return class;
}

- (CGSize)cellSize {
    CGSize size = CGSizeZero;
    CGFloat width = floor((HBScreenWidth - 24 - 24 - 12 - 12 - 12) / 4.0f);
    CGFloat height = width * 4 / 3.0 + 9 + 31;
    switch (self.style) {//6、8、9、16
        case HBChannelConfigType1:
        {
            size.width = HBScreenWidth - 12 - 12;
            size.height = 45 + height + 12;
        }
            break;
        case HBChannelConfigType2:
        {
            width = floor((HBScreenWidth - 12 - 12 - 12) / 2.0f);
            height = width * 245 / 162.0f;
            size.width = width;
            size.height = height;
        }
            break;
        case HBChannelConfigType3:
        {
            size.width = HBScreenWidth - 16 - 16;
            size.height = size.width * 300 / 656.0f;
        }
            break;
        case HBChannelConfigType4:
        {
            size.width = HBScreenWidth - 16 - 16;
            size.height = 60;
        }
            break;
        case HBChannelConfigType5:
        {
            width = 52;
            height = width * 4 / 3.0;
            size.width = HBScreenWidth - 12 - 12;
            size.height = (height + 12) * 3 + 97;
        }
            break;
        default:
            break;
    }
    return size;
}

- (UIEdgeInsets)inset {
    UIEdgeInsets inset = UIEdgeInsetsZero;
    inset.top = 12;
    inset.left = 16;
    inset.right = 16;
    switch (self.style) {
        case HBChannelConfigType1:
        case HBChannelConfigType2:
        case HBChannelConfigType5:
        {
            inset.left = 12;
            inset.right = 12;
        }
            break;
        default:
            break;
    }
    return inset;
}
@end
@implementation HBItemModel

@end
@implementation HBChannelIRankModel
+ (NSDictionary *)mj_objectClassInArray {
    return @{@"most_favors":NSClassFromString(@"HBNovelModel"),
             @"most_read":NSClassFromString(@"HBNovelModel"),
             @"newest":NSClassFromString(@"HBNovelModel")
    };
}
@end
